All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----sjl.Iter | +----sjl.InputStreamIterator
InputStreamIterator
have been created. fin = new FileInputStream("inputfile"); InputStreamIterator is = new InputStreamIterator(fin, new ReadIntegerText()); InputStreamIterator ie = new InputStreamIterator(); Algo.copy(is, ie, new BackInsertIterator(vector));The
InputStreamIterator
reads (using the
ReadIntegerText
function object) successive elements from
the input stream (fin) for which it was contructed.
When the InputStreamIterator
is contructed, and every
time next()
is used, the iterator reads and stores a value.
If the end of the stream is reached (the stream throws a EOFException),
the iterator becomes equal to the iterator end-of-stream
iterator value.
The constructor with no arguments always contructs an end of stream iterator
object which is the only legitimate iterator to be used for the end
condition.
It is impossible to store things into a InputStreamIterator
.
The main peculiarity of the
The practical consequence of this fact is that
Two end-of-stream iterators are always equal.
An end-of-stream iterator is not equal to a non-end-of-stream iterator.
Copyright © 1996 Finn Bock
InputStreamIterator
is the fact
that the
next()
method is not equality preservings,
that is i.cmp(j)
does not guarantee at all that
i.next(); j.next(); i.cmp(j)
.
Every time next()
is used a new value is returned.
InputStreamIterators
can be used only for one-pass algorithms,
which actually makes perfect sense, since for multi-pass algorithms
it is always more appropriate to use inmemory data structures.
InputStreamIterator()
InputStreamIterator(DataInputStream, Function1)
InputStreamIterator(InputStream, Function1)
cmp(Iterator)
genericCopy()
get()
next()
InputStreamIterator
public InputStreamIterator(InputStream istream,
Function1 func)
InputStreamIterator
public InputStreamIterator(DataInputStream istream,
Function1 func)
InputStreamIterator
public InputStreamIterator()
XXX: perhaps a static variable is better.
get
public Object get()
next
public Iterator next()
cmp
public boolean cmp(Iterator iterator)
genericCopy
public Iterator genericCopy()
All Packages Class Hierarchy This Package Previous Next Index